
/** ********************查询书籍类型********************** */

function  queryBookType(){

    
    var  book_type_code  = searchForm.form.findField("book_type_code").getValue()
	var  book_type_name  = searchForm.form.findField("book_type_name").getValue();
	
   	 dataStore.baseParams = {
	    'book_type_code'    : book_type_code,
		'book_type_name'    : book_type_name
	};
	dataStore.removeAll();
	dataStore.load( {
		params : {
			start : 0,
			limit : 10
		},
		callback : function(r, options, success) {
		}
	});

}

/** ********************添加书籍类型********************** */

function  addBookType(){}

/** ********************单个删除书籍类型********************** */

function  singleDelBookType(){

	var recode = dataGrid.getSelectionModel().getSelected();
	var id = recode.get('id');
	Ext.MessageBox.confirm("请确认", "是否真的要删除指定内容", function(button, text) {
		if (button == 'yes') {
			var u = '/OrderSystem/singeDelBookType.action?action=singelDel&id=' + id + '';

			Ext.Ajax.request( {
				url              : u,
				success          : function(form, action) {
					                          dataStore.reload();
					                          Ext.Msg.alert('信息', '删除成功')
				},
				failure          : function(form, action) {
					                          Ext.Msg.alert('错误信息', '删除失败')
				}

			});
		}
	});
}

/** ********************恢复单个书籍类型********************** */

function restoreBookType(){
var recode = dataGrid.getSelectionModel().getSelected();
	var id = recode.get('id');
	Ext.MessageBox.confirm("请确认", "是否真的要恢复指定数据", function(button, text) {
		if (button == 'yes') {
			var u = '/OrderSystem/restoreBookType.action?action=restore&id=' + id + '';

			Ext.Ajax.request( {
				url              : u,
				success          : function(form, action) {
					                          dataStore.reload();
					                          Ext.Msg.alert('信息', '恢复成功')
				},
				failure          : function(form, action) {
					                          Ext.Msg.alert('错误信息', '恢复失败')
				}

			});
		}
	});
}

/** ********************批量删除书籍类型********************** */

function  multiDelBookType(){
	
	var recodes = dataGrid.getSelectionModel().getSelections();
	var n = "";
	for ( var i = 0; i < recodes.length; i++) {
	  /* var  state = recodes[i].get('id');
        if(recodes[i].get('bookTypeState') == '0'){
             n = n + recodes[i].get('id') + ',';
        }*/
        
         n = n + recodes[i].get('id') + ',';
	}
	n = n.substr(0, n.length - 1);
	//n = encodeURI(encodeURI(n));
	if (n == null || n == "") {
		Ext.Msg.alert('信息', '请选择未被删除的数据');
	} else {

		Ext.MessageBox.confirm(
						"请确认","是否真的要删除指定内容",function(button, text) {
							if (button == 'yes') {
								var u = path+'/servlet/MainServlet?action=adduser&name=' + n + '';
								Ext.Ajax.request( {
									url     : u,
									success : function(form, action) {
										           dataStore.reload();
										           Ext.Msg.alert('信息', '批量删除成功');
									},
									failure : function(form, action) {
										           Ext.Msg.alert('错误', '批量删除失败');
									}

								});
							}
						});

}
}

/** ********************编辑书籍类型********************** */

function  editBookType(){
	
	var  recode = dataGrid.getSelectionModel().getSelected();
	var  id = recode.get('id');
	if   (!Ext.getCmp("showForm").getForm().isValid()) {
	 	Ext.MessageBox.alert('错误', '输入有错误，请重新输入！');
		return;
	}
	     Ext.getCmp("showForm").getForm().doAction("submit", { 
		    url     : '/OrderSystem/editBookType.action?action=editBookType&id=' + id + '',
		    success : function(form, action) {
			dataStore.reload();
			Ext.getCmp("showwin").close();
			Ext.Msg.alert('信息', action.result.msg)
		},
		failure : function(form, action) {     
			Ext.Msg.alert('错误提示', action.result.msg)
		}
	})
}

/** ********************添加书籍类型********************** */

function addBookType(){
	
	if   (!Ext.getCmp("addForm").getForm().isValid()) {
	 	Ext.MessageBox.alert('错误', '输入有错误，请重新输入！');
		return;
	}
	     Ext.getCmp("addForm").getForm().doAction("submit", { 
		    url     :path+'/servlet/MainServlet?action=adduser',
		    success : function(form, action) {
			dataStore.reload();
			Ext.getCmp("addBookTypewin").close();
			Ext.Msg.alert('信息', action.result.msg)
		},
		failure : function(form, action) {     
			Ext.Msg.alert('错误提示', action.result.msg)
		}
	})
}